/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrameUsuario.java
 *
 * Created on 29/05/2010, 02:29:45 AM
 */

package GUI.Usuario;

import GUI.Bibliotecario.AdminPrestamos.PanelBuscarLibro;
import GUI.Ingreso.FrameAcercaDe;
import MainBiblioSoft.BiblioSoft;
import Manuales.Ayuda;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

/**
 *
 * @author sebaxtian
 */
public class FrameUsuario extends javax.swing.JFrame {

    private PanelBuscarLibro panelBuscarLibro;
    private FrameAcercaDe frameAcercaDe;
    private TrayIconFrameUsuario trayIconFrameUsuario;
    private int cantIconBandeja;

    /** Creates new form FrameUsuario */
    public FrameUsuario() {
        initComponents();
        this.setLocationRelativeTo(null);
        this.setIconImage (new ImageIcon(getClass().getResource("/Imagenes/IconBiblioSoft1.png")).getImage());
        panelBuscarLibro = new PanelBuscarLibro();
        frameAcercaDe = new FrameAcercaDe();
        trayIconFrameUsuario = new TrayIconFrameUsuario(this);
        cantIconBandeja = 0;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelScroll = new javax.swing.JScrollPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        menuLimpiar = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        menuSalir = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();
        menuBuscarLibro = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        menuManual = new javax.swing.JMenuItem();
        menuAcercaDe = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("BiblioSoft :: Usuario");
        setMinimumSize(new java.awt.Dimension(650, 650));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });
        getContentPane().add(panelScroll, java.awt.BorderLayout.CENTER);

        jMenu1.setText("Archivo");

        menuLimpiar.setText("Limpiar");
        menuLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuLimpiarActionPerformed(evt);
            }
        });
        jMenu1.add(menuLimpiar);
        jMenu1.add(jSeparator1);

        menuSalir.setText("Salir");
        menuSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuSalirActionPerformed(evt);
            }
        });
        jMenu1.add(menuSalir);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edicion");

        jMenu3.setText("Libro");

        menuBuscarLibro.setText("Buscar");
        menuBuscarLibro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuBuscarLibroActionPerformed(evt);
            }
        });
        jMenu3.add(menuBuscarLibro);

        jMenu2.add(jMenu3);

        jMenuBar1.add(jMenu2);

        jMenu4.setText("Ayuda");

        menuManual.setText("Manual");
        menuManual.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuManualActionPerformed(evt);
            }
        });
        jMenu4.add(menuManual);

        menuAcercaDe.setText("Acerca de");
        menuAcercaDe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuAcercaDeActionPerformed(evt);
            }
        });
        jMenu4.add(menuAcercaDe);

        jMenuBar1.add(jMenu4);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuBuscarLibroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuBuscarLibroActionPerformed
        // TODO add your handling code here:
        panelScroll.setViewportView(panelBuscarLibro);
    }//GEN-LAST:event_menuBuscarLibroActionPerformed

    private void menuLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuLimpiarActionPerformed
        // TODO add your handling code here:
        panelScroll.setViewportView(new JLabel());
    }//GEN-LAST:event_menuLimpiarActionPerformed

    private void menuSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSalirActionPerformed
        // TODO add your handling code here:
        this.setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
        this.dispose();
        trayIconFrameUsuario.eliminarIconoEnBandeja();
        BiblioSoft.main(null);
    }//GEN-LAST:event_menuSalirActionPerformed

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        // TODO add your handling code here:
        this.setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
    }//GEN-LAST:event_formWindowClosed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
        if(cantIconBandeja == 0){
            try{
                trayIconFrameUsuario.crearIconoEnBandeja();
                this.setVisible(false);
                cantIconBandeja = 1;
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage(), "Icono En Bandeja", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    }//GEN-LAST:event_formWindowClosing

    private void menuManualActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuManualActionPerformed
        // TODO add your handling code here:
        new Ayuda(Ayuda.PERFILUSUARIO);
    }//GEN-LAST:event_menuManualActionPerformed

    private void menuAcercaDeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuAcercaDeActionPerformed
        // TODO add your handling code here:
        frameAcercaDe.setVisible(true);
    }//GEN-LAST:event_menuAcercaDeActionPerformed

    /**
    * @param args the command line arguments
    */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new FrameUsuario().setVisible(true);
//            }
//        });
//    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JMenuItem menuAcercaDe;
    private javax.swing.JMenuItem menuBuscarLibro;
    private javax.swing.JMenuItem menuLimpiar;
    private javax.swing.JMenuItem menuManual;
    private javax.swing.JMenuItem menuSalir;
    private javax.swing.JScrollPane panelScroll;
    // End of variables declaration//GEN-END:variables

}
